-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add From<Uuid>
implementation for Handle<A>
#21394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add From<Uuid>
implementation for Handle<A>
#21394
Conversation
Implements conversion from Uuid to Handle<A> for easier handle creation. This provides a more ergonomic API when working with dynamic asset UUIDs. Closes bevyengine#21349
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
the only issue here is that you would only be able to pass an i would go for |
It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note. Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes. |
Generally yes, but not in that particular case. Those versions are semver compatible, so cargo update will deduplicate them for you. Users shouldn't have two distinct versions of uuid in their tree. |
They are until they aren't, speaking from experience, some people still haven't fully grasped the meaning of patch version, not talking explicitly about
|
Let's cross that bridge when we get to it? If needed, we can re-export the |
Co-authored-by: François Mockers <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat, I like these kinds of From
impls for enum
s :) I didn't need this particular one yet, but I can see it being useful while converting types around e.g. during ser/de
## Objective Closes bevyengine#21349 Provides an ergonomic way to create a `Handle<A>` from a `Uuid` at runtime. ## Solution Implements the `From<Uuid>` trait for `Handle<A>`, allowing users to write: ```rust let uuid = Uuid::new_v4(); let handle: Handle<Image> = uuid.into(); ``` Instead of the current verbose approach: ```rust let handle = Handle::<Image>::Uuid(uuid, PhantomData); ``` ## Testing - Added comprehensive test `from_uuid` that verifies: - Conversion from `Uuid` to `Handle<A>` works correctly - The resulting handle is a UUID variant - The handle ID matches the input UUID - Both `.into()` and explicit `From::from()` work - All existing handle tests continue to pass - Clippy and formatting checks pass --------- Co-authored-by: Alice Cecile <[email protected]> Co-authored-by: François Mockers <[email protected]>
Objective
Closes #21349
Provides an ergonomic way to create a
Handle<A>
from aUuid
at runtime.Solution
Implements the
From<Uuid>
trait forHandle<A>
, allowing users to write:Instead of the current verbose approach:
Testing
from_uuid
that verifies:Uuid
toHandle<A>
works correctly.into()
and explicitFrom::from()
work